<template>
  <div>
    <el-button type="danger" size="small" @click="open()">删除</el-button>
  </div>
</template>

<script>
import qs from 'qs'
export default {
  inject:['reload'],
  name: "TypeDelete",
  props:['typeName','clickRate'],
  methods:{
    deleteType(){
      if (this.clickRate!==0){
        this.$message.warning("该分类下还有博客，无法删除");
      }else {
        this.axios.post('/blog/deleteType',qs.stringify({
          type:this.typeName,
        })).then((response)=>{
          this.$message.success(response.data.tip);
          this.reload();
        })
      }
    },
    open() {
      this.$confirm('是否确认删除标签?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteType();
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
  }
}
</script>

<style scoped>

</style>
